//用于定义权限控制的自定义指令
import { App } from "vue";
import { useUserStore } from "@/store/module/user";

export const regPermission = (app: App<Element>) => {
  app.directive("permission", {
    // 钩子函数
    mounted(el, binding) {
      const userStore = useUserStore();
      console.log("自定义指令：", el, binding);

      //   //从仓库数据中判断是否存在binding.value, 如果不存在，没有权限，删除dom元素
      if (!userStore.getPermitions.includes(binding.value)) {
        el.remove();
      }
    },
  });
};
